Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@thi.ng/random

Package Overview
Dependencies
Maintainers
0
Versions
184
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/random

Pseudo-random number generators w/ unified API, distributions, weighted choices, ID generation

  • 4.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created

What is @thi.ng/random?

@thi.ng/random is a versatile library for generating random numbers and sequences. It provides various random number generators (RNGs) and utilities for creating random values, sequences, and distributions.

What are @thi.ng/random's main functionalities?

Basic Random Number Generation

This feature allows you to generate basic random numbers, both floating-point and integer values, using the default system RNG.

const { SYSTEM } = require('@thi.ng/random');
const rng = SYSTEM;
console.log(rng.float()); // Generates a random float between 0 and 1
console.log(rng.int()); // Generates a random integer

Seeded Random Number Generation

This feature allows you to create a seeded random number generator, which produces reproducible sequences of random numbers.

const { XsAdd } = require('@thi.ng/random');
const rng = new XsAdd(12345); // Seeded RNG
console.log(rng.float()); // Generates a reproducible random float
console.log(rng.int()); // Generates a reproducible random integer

Random Value Generation from Arrays

This feature allows you to randomly select values from an array, which is useful for shuffling or sampling data.

const { SYSTEM } = require('@thi.ng/random');
const rng = SYSTEM;
const arr = [1, 2, 3, 4, 5];
console.log(rng.choice(arr)); // Randomly selects an element from the array

Random Distributions

This feature allows you to generate random numbers from various statistical distributions, such as normal (Gaussian) distributions.

const { SYSTEM } = require('@thi.ng/random');
const rng = SYSTEM;
console.log(rng.norm(0, 1)); // Generates a random number from a normal distribution with mean 0 and standard deviation 1

Other packages similar to @thi.ng/random

Keywords

FAQs

Package last updated on 10 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc